import formJs from "./regexDetail.js"; //新增弹框配置项
import publicForm from "@/components/public/el-form.vue"; //弹框form
import TableData from "@/components/public/el-table-pagination"; //列表


import {
    getPileFoundationDrillingChannel, //通道参数
    getPileFoundationDrillingChannelData, //孔径通道
    getPileFoundationDrillingChannelAnalysis //孔径分析
} from "@/api/request.js";


export default {
    props: [
        "dialogVisible", //弹框是否展示
        "dialogTitle", //标题
        "statusNum", //按钮编号 1新增   2编辑取样   3编辑收样  7查看
        "currentRow", //当前行
        "fCompanyid",
        "fCompanyname",

    ],
    data() {
        return {

            // 页签切换
            typeData: [{
                    text: "通道参数",
                    show: true
                },
                {
                    text: "孔径通道采样数据",
                    show: false
                },
                {
                    text: "孔径分析数据",
                    show: false
                },
            ],
            // 页签切换
            visible: "", //弹框展示隐藏
            title: null, //弹框标题
            dialogHeight: null, //弹框高度
            table_config1: formJs.table_config1, //列表
            tableData1: [],
            queryCriteriaData1: null,
            getList1: {
                fId: "", // 列表页数据的fid
                page: 1, // 当前页码
                pageSize: 20 // 每页显示条数
            },
            loading1: false, //列表转载
            table_config2: formJs.table_config2, //列表
            tableData2: [],
            queryCriteriaData2: null,
            getList2: {
                fId: "", // 列表页数据的fid
                page: 1, // 当前页码
                pageSize: 20 // 每页显示条数
            },
            loading2: false, //列表转载
            table_config3: formJs.table_config3, //列表
            tableData3: [],
            queryCriteriaData3: null,
            getList3: {
                fId: "", // 列表页数据的fid
                page: 1, // 当前页码
                pageSize: 20 // 每页显示条数
            },
            loading3: false, //列表转载



        };
    },
    components: {
        publicForm,
        TableData,
    },
    watch: {
        dialogVisible: {
            handler(newVal) {
                if (newVal) {
                    this.visible = newVal;
                }
            },
            immediate: true,
        },
        dialogTitle: {
            handler(newVal) {
                if (newVal) {
                    this.title = newVal;
                }
            },
            immediate: true,
        },


        currentRow: {
            handler(newVal) {
                if (newVal) {
                    this.currentDetail = newVal;
                }
            },
            immediate: true,
        },

        fCompanyid: {
            handler(newVal) {
                if (newVal) {

                    this.fCompanyids = newVal

                }
            },
            immediate: true,
        },
        fCompanyname: {
            handler(newVal) {
                if (newVal) {
                    this.fCompanynames = newVal

                }
            },
            immediate: true,
        },

    },
    created() {
        window.addEventListener("resize", this.getHeight);
        this.getHeight();
    }, //获取页面高度自适应：

    destroyed() {
        window.removeEventListener("resize", this.getHeight);
        this.getHeight();
    },
    mounted() {
        this.userInfo = JSON.parse(sessionStorage.getItem("yjSmart-userInfo"));
        // console.log("userInfo", this.userInfo);

        if (this.statusNum == 7) { //查看
            this.btnShow = false //按钮
           this.getList1.fId=this.currentDetail.fId
           this.getList2.fId=this.currentDetail.fId
           this.getList3.fId=this.currentDetail.fId

            this.getDetail1(this.getList1)
            this.getDetail2(this.getList2)

            this.getDetail3(this.getList3)


        }
        this.getHeight();

    },
    methods: {
        // 页签切换
        changeType(e, index) {
            for (let i in this.typeData) {
                if (parseFloat(i) === index) {
                    this.typeData[i].show = true;
                } else {
                    this.typeData[i].show = false;
                }
            }
            // this.typeDataNum = index;
        },
        // 页签切换
        getHeight() {
            var h = document.documentElement.clientHeight; //获取页面可见高度
            this.dialogHeight = h * 0.76 + "px";
        },

        closeDialog() {
            this.$emit("close");
        },

        // 详情
        // 详情
        getDetail1(obj) {
            console.log(1,obj);

            this.loading1 = true;
            getPileFoundationDrillingChannel(obj).then((res) => {
                if (res.errcode == 0) {
                    this.loading1 = false;

                    this.tableData1 = res.data.channelList.list
                    this.queryCriteriaData1 = res.data.channelList;
                } else {
                    this.loading1 = false;
                    this.$message.error(res.msg);
                }
            });
        },
        getDetail2(obj) {
            console.log(2,obj);

            this.loading2 = true;
            getPileFoundationDrillingChannelData(obj).then((res) => {
                if (res.errcode == 0) {
                    this.loading2 = false;

                    this.tableData2 = res.data.channelDataList.list
                    this.queryCriteriaData2 = res.data.channelDataList;
                } else {
                    this.loading2 = false;
                    this.$message.error(res.msg);
                }
            });
        },
        getDetail3(obj) {
            console.log(3,obj);
            this.loading3 = true;
            getPileFoundationDrillingChannelAnalysis(obj).then((res) => {
                if (res.errcode == 0) {
                    this.loading3 = false;

                    this.tableData3 = res.data.channelAnalysisList.list
                    this.queryCriteriaData3 = res.data.channelAnalysisList;
                } else {
                    this.loading3 = false;
                    this.$message.error(res.msg);
                }
            });
        },

    },
};